package com.rpay.dao.trade;

import com.rpay.model.trade.TradeCacheDO;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

@Repository
public class TradeCacheDAO {

    @Autowired
    @Qualifier("readSqlSession")
    private SqlSessionTemplate readSqlSession;

    @Autowired
    @Qualifier("writeSqlSession")
    private SqlSessionTemplate writeSqlSession;

    public int insert(TradeCacheDO tradeCacheDO) {
        return writeSqlSession.insert("rpay.trade.insert", tradeCacheDO);
    }

    public int update(TradeCacheDO tradeCacheDO) {
        return writeSqlSession.update("rpay.trade.update", tradeCacheDO);
    }

    public TradeCacheDO findOne() {
        return readSqlSession.selectOne("rpay.trade.first", 0);
    }
}
